package mainScreen;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

import sidebar.Sidebar;
import ui.ImageButton;


public class MainMenu implements MainScreen, ActionListener{
	JPanel screenPanel; //the main panel for the entire screen
	Sidebar sidebar;
	
	public MainMenu()
	{
		screenPanel = new JPanel();
		screenPanel.setLayout(null);
	}
	
	@SuppressWarnings("unused")
	//TODO: Consider fixing
	public void initiate(Sidebar sidebar)
	{
		//TODO: Initialize main menu
		JLabel label = new JLabel("Main Menu");
		label.setBounds(200, 200, 800, 100);
		ImageButton newGameBtn = ImageButton.spawnButton ("button", "New Game", "NewGame", this, screenPanel, 260, 260, sidebar.getOptions());
		ImageButton saveGameBtn = ImageButton.spawnButton ("button", "Save Game", "SaveGame", this, screenPanel, 260, 360, sidebar.getOptions());
		saveGameBtn.setEnabled(false);
		ImageButton loadGameBtn = ImageButton.spawnButton ("button", "Load Game", "LoadGame", this, screenPanel, 260, 460, sidebar.getOptions());
		ImageButton exitGameBtn = ImageButton.spawnButton ("button", "Exit Game", "Exit", this, screenPanel, 260, 560, sidebar.getOptions());
		screenPanel.add(label);
		this.sidebar = sidebar;
	}
	
	public JPanel getPanel()
	{
		return screenPanel;
	}

	public String getScreenType()
	{
		return "MainMenu";
	}
	
	public void endTurn()
	{
		//I don't think there is anything that needs to happen here
	}

	public void repaint()//repaint all relevant components
	{
		screenPanel.repaint();
	}

	public void actionPerformed(ActionEvent event)
	{
		switch(event.getActionCommand())
		{
		case "Exit": 
			sidebar.actionPerformed(event);
			break;
		case "NewGame":
			ActionEvent eventy = new ActionEvent(event.getSource(), event.getID(), "MainMenu_"+event.getActionCommand());
			sidebar.actionPerformed(eventy);
			break;
		default:
			System.err.println(event.getActionCommand() + " in 'MainMenu' is not implemented yet. Got implement it.");
		}
	}
}

